package com.car.order.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.car.order.dto.goodOrderLog.GoodOrderLogDto;
import com.car.order.entity.GoodOrderLog;
import com.car.order.entity.form.goodOrderLog.GoodOrderLogFindListForm;
import com.car.order.entity.form.goodOrderLog.GoodOrderLogFindPageForm;
import com.car.order.entity.form.goodOrderLog.GoodOrderLogInsertForm;
import com.car.order.entity.form.goodOrderLog.GoodOrderLogUpdateForm;
import com.car.commons.core.model.Result;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;

import org.springframework.web.bind.annotation.*;
import com.car.order.service.GoodOrderLogService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;

/**
 *
 *
 * @author 杜岷芫
 * @since 2024-08-28 19:25:28
 */
@RestController
@RequestMapping("/goodOrderLog")
@Api(tags = "商品订单日志")
public class GoodOrderLogController {

    @Autowired
    private GoodOrderLogService goodOrderLogService;

    /**
     * 分页查询
     *
     * @param form
     * @return
     */
    @ApiOperation(value = "分页查询")
    @PostMapping("/findPage")
    public Result findPage(@RequestBody GoodOrderLogFindPageForm form) {
        Page<GoodOrderLog> result = goodOrderLogService.findPage(form);
        return Result.getResult().setMsg("查询成功").setData(result);
    }
    /**
     * 列表查询
     *
     * @param form
     * @return
     */
    @ApiOperation(value = "列表查询")
    @PostMapping("/findList.pt")
    public Result findList(@RequestBody GoodOrderLogFindListForm form) {
        List<GoodOrderLogDto> result = goodOrderLogService.findList(form);
        return Result.getResult().setMsg("查询成功").setData(result);
    }

    /**
     * 查询
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "根据id查询详情")
    @GetMapping("/{id}")
    public Result findById(@PathVariable("id") Integer id) {
        GoodOrderLog goodOrderLog = goodOrderLogService.findById(id);
        return Result.getResult().setMsg("查询成功").setData(goodOrderLog);
    }

    /**
     * 新增
     *
     * @param form
     * @return
     */
    @ApiOperation(value = "新增")
    @PostMapping
    public Result insert( @RequestBody GoodOrderLogInsertForm form) {
        GoodOrderLog goodOrderLog = goodOrderLogService.insert(form);
        return Result.getResult().setMsg("操作成功").setData(goodOrderLog);
    }

    /**
     * 修改
     *
     * @param form
     * @return
     */
    @ApiOperation(value = "修改")
    @PutMapping
    public Result update( @RequestBody GoodOrderLogUpdateForm form) {
        GoodOrderLog goodOrderLog = goodOrderLogService.update(form);
        return Result.getResult().setMsg("操作成功").setData(goodOrderLog);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "删除")
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable("id") Integer id) {
        goodOrderLogService.delete(id);
        return Result.getResult().setMsg("操作成功");
    }

}